<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <!-- 引用 favicon.ico 文件 -->
    <link rel="icon" href="img/dco-logo.png" type="image/x-icon">
    <title>开发者原创声明提交页面</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <style>

        body {
            background-color: #f0f0f0; /* 可以设置一个背景颜色以替代背景图片 */
            margin: 0;
            padding: 0;
        }
        .header {
            margin: 20px;
            font-size: 48px;
            font-weight: bold;
            text-align: left;
        }
        .container {
            justify-content: center; /* 使内容居中 */
            align-items: center;
            padding: 20px;
            background-color: #fff; /* 设置背景颜色 */
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* 添加阴影效果 */
            border-radius: 10px; /* 添加圆角 */
            max-width: '95%'; /* 根据需要调整最大宽度 */
            margin: 0 auto; /* 使容器居中 */
        }
        .footer {
            position: fixed;
            bottom: 0;
            width: 100%;
            background-color: #333;
            color: #fff;
            text-align: center;
            padding: 10px 0;
            font-size: 14px;
        }
        .myBtn {
            width: 15rem;
            height: 3rem;
            font-size: 1.3rem;
            margin: 1.2rem 0;
            border-radius: 2rem;
        }
        .myBtn, .myBtn:active, .myBtn:focus, .myBtn:hover {
            color: #fff;
            background: linear-gradient(90deg, #87CEEB, #B0E0E6);  /* 浅蓝色渐变 */
        }
        .get-captcha-btn {
            display: inline-block;
            height: 38px;
            line-height: 38px;
            padding: 0 18px;
            background-color: #009688;
            color: #fff;
            white-space: nowrap;
            text-align: center;
            font-size: 14px;
            border: none;
            border-radius: 2px;
            cursor: pointer;
        }
        .get-captcha-btn.disabled {
            background-color: #ccc;
            cursor: not-allowed;
        }
        .captcha-wrapper {
            display: flex;
            align-items: center;
        }

        .captcha-wrapper .layui-input {
            flex: 1;
            margin-right: 10px; /* 调整输入框和按钮之间的间距 */
        }
        /* 新增的样式 */
        .privacy-policy-link {
            display: inline-flex; /* 使用 flex 布局 */
            align-items: center; /* 垂直居中 */
            text-decoration: underline; /* 添加下划线 */
        }
    </style>
</head>
<body>
<div class="header"><a href="https://atomgit.com/">AtomGit</a></div>
<div class="layui-container container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <h2 style="font-size: 56px; font-weight: bold;">开发者原创声明</h2>
        </div>
        <div class="layui-col-md12">
            <h2 style="font-size: 1.8rem; font-weight: bold;">Developer Certificate of Origin</h2>
            <h2 style="font-size: 1.8rem; font-weight: bold;">开发者原创声明</h2>
            <p><strong>Version 1.1</strong></p>
            <p><strong>第1.1版</strong></p>
            <br>
            <p>Copyright (C) 2004, 2006 The Linux Foundation and its contributors.</p>
            <p>版权所有(C)2004,2006 Linux基金会及其贡献者。</p>
            <p>1 Letterman Drive</p>
            <p>莱特曼大道1号</p>
            <p>Suite D4700</p>
            <p>D4700室</p>
            <p>San Francisco, CA, 94129</p>
            <p>加利福尼亚州旧金山市94129</p>
            <br>
            <p>Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.</p>
            <p>任何人均可复制和分发本许可文件副本，但不得修改。</p>
            <br>
            <hr style="border: none; border-top: 1px dashed #ccc; margin: 20px 0;">
            <h3 style="font-size: 1.6rem; font-weight: bold;">Developer's Certificate of Origin 1.1</h3>
            <h3 style="font-size: 1.6rem; font-weight: bold;">开发者原创声明（第1.1版）</h3>
            <br>
            <p>By making a contribution to this project, I certify that:</p>
            <p>在向本项目提交贡献之时，本人声明：</p>
            <br>
            <p>(a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or</p>
            <p>(a) 该贡献全部或部分由本人创作，且本人有权根据当前文件中所示的开源许可证提交；或</p>
            <br>
            <p>(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or</p>
            <p>(b) 尽本人所知，该贡献所基于的在先作品已经过适当的开源许可证授权，且根据该开源许可证，本人有权在相同开源许可证（如当前文件中所示）下提交该修改后的作品（除非本人被允许根据不同的许可证提交），不论其是否全部或部分由本人创作；或</p>
            <br>
            <p>(c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.</p>
            <p>(c) 该贡献是由作出(a)、(b) 或(c) 声明的其他人直接提供给本人，且本人未对其进行修改。</p>
            <br>
            <p>(d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.</p>
            <p>(d) 本人理解并同意，本项目及贡献是公开的，且贡献（包括本人随附提交的全部个人信息，含本人签字）将被无限期存档，并可以与本项目或所涉开源许可证保持一致的情形下再被分发。</p>
            <br>
            <hr style="border: none; border-top: 1px dashed #ccc; margin: 20px 0;">
            <p>Above Chinese version of the Developer's Certificate of Origin is translated by the OpenAtom Foundation.</p>
            <p>以上开发者原创声明中文版本由开放原子开源基金会翻译。</p>
            <br>
        </div>

        <div class="layui-col-md12">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" required lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">邮箱</label>
                    <div class="layui-input-block">
                        <input type="email" name="email" required lay-verify="required" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">验证码</label>
                    <div class="layui-input-block">
                        <div class="captcha-wrapper">
                            <input type="text" name="captcha" required  placeholder="请输入验证码" autocomplete="off" class="layui-input">
                            <button id="getCaptchaBtn" type="button" class="get-captcha-btn" lay-submit lay-filter="captureFormDemo">获取验证码</button>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input type="checkbox" name="agree"  required lay-verify="required" autocomplete="off" title="本人已阅读并理解以上开发者原创声明内容及适用的隐私政策，本人同意签署并遵守该声明" >
                        <a href="https://docs.atomgit.com/agreements/privacy" target="_blank" class="privacy-policy-link">隐私政策</a>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn myBtn" lay-submit lay-filter="formDemo">我同意签署</button>
                    </div>
                </div>
            </form>
        </div>

    </div>
</div>
<div class="footer" style="text-align: center;">
    <p>©2025 开放原子开源基金会 版权所有  京ICP备2020036654号-4  京公网安备 11030102011541号</p>
</div>

<script src="../layui/layui.js"></script>
<script>
    layui.use(['form','jquery','layer'], function(){
        var form = layui.form;
        var $ = layui.jquery; // 引入jQuery模块
        var layer = layui.layer; // 引入layer模块
        // 创建 URLSearchParams 对象
        const urlParams = new URLSearchParams(window.location.search);
        // 获取指定参数的值
        const aid = Number(urlParams.get('aid'));
        if (aid === null || isNaN(aid)) {
            layer.msg('错误：请获取正确的授权地址', { icon: 2 });
        }
        form.render();

        // 监听提交
        form.on('submit(formDemo)', function(data){
            console.log(data.field);
            if (aid === null || isNaN(aid)) {
                layer.msg('错误：请获取正确的授权地址', { icon: 2 });
                return false;
            }
            if (!data.field.agree) {
                layer.msg('点击同意签署声明', {icon: 2, time: 2000});
                return false;
            }
            if (!data.field.captcha) {
                layer.msg('验证码不能为空', {icon: 2, time: 2000});
                return false;
            }
            // 发送POST请求
            $.ajax({
                url: '/api/v1/signdco', // 目标URL
                type: 'POST', // 请求类型为POST
                contentType: 'application/json', // 设置内容类型为json
                data: JSON.stringify({
                    name: data.field.name,
                    email: data.field.email,
                    aid:aid,
                    verifyCode: data.field.captcha
                }), // 发送的数据需要转换为JSON字符串
                processData: false, // 不处理发送的数据，使其保持为JSON字符串
                success: function(res){
                    // 请求成功后的回调函数
                    console.log(res);
                    layer.msg('签署成功', {
                        icon: 1, // 图标类型，1表示成功图标
                        time: 2000 // 消息框显示的时间，单位为毫秒
                    },function(){
                        // 消息框关闭后的回调
                        window.location.href = '/static/dco/sign.html?aid=' + aid; // 跳转到目标页面
                    });

                },
                error: function(err){
                    // 请求失败后的回调函数
                    console.error(err);
                    layer.msg(err.responseText, {
                        icon: 2, // 图标类型，1表示成功图标
                        time: 2000 // 消息框显示的时间，单位为毫秒
                    })
                }
            });
            // 这里可以添加提交表单的具体逻辑
            return false; // 阻止表单跳转、、

        });

        // 获取验证码按钮点击事件
        var countdown = 60;
        var timer = null;
        form.on('submit(captureFormDemo)', function(data){
            if (aid === null || isNaN(aid)) {
                layer.msg('错误：请获取正确的授权地址', { icon: 2 });
                return false;
            }
            if (!data.field.name) {
                layer.msg('姓名不能为空', {icon: 2, time: 2000});
                return false;
            }

            if (!data.field.email) {
                layer.msg('邮箱不能为空', {icon: 2, time: 2000});
                return false;
            }

            var $this = $('#getCaptchaBtn')
            if (!$this.hasClass('disabled')) {
                // 发送获取验证码请求
                $.ajax({
                    url: '/api/v1/getCaptcha', // 假设的获取验证码接口
                    type: 'POST',
                    contentType: 'application/json', // 设置内容类型为json
                    data: JSON.stringify({
                        name: data.field.name,
                        email: data.field.email,
                        aid:aid,
                    }), // 发送的数据需要转换为JSON字符串
                    success: function(res) {
                        console.log(res);
                        layer.msg('验证码已发送邮箱，请查收', {
                            icon: 1,
                            time: 2000
                        });
                        // 开始倒计时
                        $this.addClass('disabled');
                        $this.text(countdown + ' 秒后可重新获取');
                        timer = setInterval(function() {
                            countdown--;
                            if (countdown > 0) {
                                $this.text(countdown + ' 秒后可重新获取');
                            } else {
                                clearInterval(timer);
                                countdown = 60;
                                $this.removeClass('disabled');
                                $this.text('获取验证码');
                            }
                        }, 1000);
                    },
                    error: function(err) {
                        console.error(err);
                        layer.msg(err.responseText, {
                            icon: 2,
                            time: 2000
                        });
                    }
                });
            }
        });
    });
</script>
</body>
</html>